package com.example.controller.report;

import com.example.common.result.PageResult;
import com.example.common.result.Result;
import com.example.entity.dto.MouldReportDto;
import com.example.entity.dto.WorkReportDto;
import com.example.entity.vo.WorkReportVo;
import com.example.entity.vo.weixiubaoyang.MouldReportVo;
import com.example.service.report.ReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

@RestController
@Api(tags = "报表")
@Slf4j
@RequestMapping("/api/report")
public class ReportController {

    @Autowired
    private ReportService reportService;

    @ApiOperation("OEE生产日报表")
    @PostMapping("OEEdailyReport")
    public Result OEEdailyReport() {

        return Result.success();
    }

    /**
     * 工单报表
     * @param dto
     * @return
     */
    @ApiOperation("工单报表")
    @GetMapping("workReport")
    public Result<PageResult<WorkReportVo>> workOrderReport(WorkReportDto dto) {
        PageResult<WorkReportVo> pageResult = reportService.workOrderPage(dto);
        return Result.success(pageResult);
    }

    /**
     * 模具履历报表
     * @return
     */
    @ApiOperation("模具履历报表")
    @PostMapping("mouldReport")
    public Result<MouldReportVo> mouldReport(@RequestBody MouldReportDto dto) {
        MouldReportVo mouldReportVo = reportService.mouldReport(dto);
        return Result.success(mouldReportVo);
    }

    /**
     * 导出模具履历报表
     */
    @ApiOperation("导出模具履历报表")
    @PostMapping("exportMould")
    public void exportMould(@RequestBody MouldReportDto dto, HttpServletResponse response) {
        reportService.exportMould(dto,response);
    }
}
